package com.chuanyang.driverh.mainmy;

import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseTitleActivity;
import com.chuanyang.driverh.responseresult.AccountBalanceResult;
import com.chuanyang.driverh.utils.ActivityUtil;
import com.chuanyang.driverh.utils.DialogUtil;
import com.chuanyang.driverh.utils.PrintUtil;
import com.chuanyang.driverh.utils.SharedPrefUtil;
import com.chuanyang.driverh.utils.net.JsonGenericsSerializator;
import com.chuanyang.driverh.utils.net.MyCallback;
import com.chuanyang.driverh.utils.net.MyHttpUtil;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;


/**
 *
 */

public class WalletActivity extends BaseTitleActivity {
    private RelativeLayout rl_account_money;//账户余额
    private RelativeLayout rl_order_bill_detail;//账单明细
    private RelativeLayout rl_account_fund;//基金
    private RelativeLayout rl_account_bank_card;//银行卡

    private RelativeLayout rl_order_statistics;//订单统计
    private RelativeLayout rl_order_billdetails;//账单明细

    private   TextView tv_wallent_income;
    private  TextView tv_wallet_totalrepay;
    private TextView tv_accoount_money;
    private  TextView tv_accoount_fund;
    private  TextView tv_accoount_bank_card;


    @Override
    protected int getContentResId() {
        return R.layout.my_act_wallet;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        rl_account_money = (RelativeLayout) findViewById(R.id.rl_account_money);
        rl_order_bill_detail = (RelativeLayout) findViewById(R.id.rl_order_bill_detail);
        rl_account_fund = (RelativeLayout) findViewById(R.id.rl_account_fund);
        rl_account_bank_card = (RelativeLayout) findViewById(R.id.rl_account_bank_card);

        rl_order_statistics = (RelativeLayout) findViewById(R.id.rl_order_statistics);
        rl_order_billdetails = (RelativeLayout) findViewById(R.id.rl_order_billdetails);

        tv_wallent_income = (TextView) findViewById(R.id.tv_wallent_income);
        tv_wallet_totalrepay = (TextView) findViewById(R.id.tv_wallet_totalrepay);
        tv_accoount_money = (TextView) findViewById(R.id.tv_accoount_money);
        tv_accoount_fund = (TextView) findViewById(R.id.tv_accoount_fund);
        tv_accoount_bank_card = (TextView) findViewById(R.id.tv_accoount_bank_card);
    }

    @Override
    protected void initData() {
        setBackImg();
        getTitleTextView().setText("钱包");

    }

    @Override
    protected void initListener() {

        rl_account_money.setOnClickListener(this);
        rl_order_bill_detail.setOnClickListener(this);
        rl_account_fund.setOnClickListener(this);
        rl_account_bank_card.setOnClickListener(this);
        rl_order_statistics.setOnClickListener(this);
        rl_order_billdetails.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.rl_account_money://进入到账户余额的界面
                ActivityUtil.startActivity(activityContext,AccountMoneyActivity.class);
                break;
            case R.id.rl_order_bill_detail://进入到账户余额的界面
                PrintUtil.toast(activityContext,"该功能未开通");
//                ActivityUtil.startActivity(activityContext,AccountMoneyActivity.class);
                break;
            case R.id.rl_account_fund://进入到基金的界面
                ActivityUtil.startActivity(activityContext,AccountFundActivity.class);
                break;
            case R.id.rl_account_bank_card://进入到银行卡的界面
//                startActivity(AccountBankCardActivity.class);
                break;
            case R.id.rl_order_statistics://订单统计
                PrintUtil.toast(activityContext,"该功能未开通");
                break;
            case R.id.rl_order_billdetails://跳转到账单明细的界面
                PrintUtil.toast(activityContext,"该功能未开通");
                break;
        }
    }


    private void getAccountBalance() {
        DialogUtil.showLoadingDialog(activityContext,"账户...");
        Map<String,String> params=new HashMap<String, String>();
        params.put("userId", SharedPrefUtil.getUserId());
        params.put("accountType","1");

        MyHttpUtil.getAccountById(activityContext,params, new MyCallback<AccountBalanceResult>(activityContext,new JsonGenericsSerializator()) {
            @Override
            public void onFail(Call call, Exception e, int id) {

                e.printStackTrace();
                PrintUtil.toast(activityContext, "网络异常，请稍后再试");
            }

            @Override
            public void onSuccess(AccountBalanceResult result, int id) {

            }

        });
    }
}
